package cur.nature.tinyorm.core.proxy;

import cur.nature.tinyorm.core.bean.PageBean;

import java.util.List;
import java.util.Map;

public interface TemplateProxy {

    // 获取所有字段
    String getColumns(Class<?> clazz);

    // 获取所有字段
    String getColumns(Class<?> clazz, String prefix);

    // 获取表名
    String getTableName(Class<?> clazz);

    // 查询列表
    Map<String, Object> queryMap(String sql, Map<String, Object> param);

    // 分页查询
    <T> PageBean<T> queryForPage(String sql, PageBean<T> pagination, Class<T> resultType) throws Exception;

    // 分页查询
    <T> PageBean<T> queryForPage(String sql, PageBean<T> pagination,
                                 Map<String, Object> param, Class<T> resultType) throws Exception;

    // 分页查询
    <T> PageBean<T> queryForPage(String sql, Object[] param, PageBean<T> pagination, Class<T> resultType) throws Exception;

    // 查询列表
    <T> List<T> queryForListCust(String sql, Class<T> resultType) throws Exception;

    // 查询列表
    <T> List<T> queryForListCust(String sql, Map<String, Object> param, Class<T> resultType) throws Exception;

    // 查询列表
    <T> List<T> queryForListJdbc(String sql, Map<String, Object> param, Class<T> resultType) throws Exception;

    // 查询
    <T> T queryForObjectCust(String sql, Class<T> resultType) throws Exception;

    // 查询列表
    List<Map<String, Object>> queryList(String sql, Map<String, Object> param);

    // 查询列表
    List<Map<String, Object>> queryList(String sql, Object[] param);

    // 插入
    int insert(Object obj, boolean isAllColumns) throws IllegalAccessException;

    // 插入
    int insert(Object obj, String tableName, boolean isAllColumns) throws IllegalAccessException;

    // 批量插入
    int[] batchInsert(List list) throws IllegalAccessException;

    // 批量插入
    int[] batchInsert(List list, String tableName) throws IllegalAccessException;

    // 批量插入
    int update(Object obj, String condition,
               boolean isAllColumns, boolean updateById) throws IllegalAccessException;

    // 更新
    int update(Object obj, String condition,
               boolean isAllColumns, boolean updateById, String tableName) throws IllegalAccessException;

    // 更新
    int[] batchUpdate(List list, boolean updateById, String tableName) throws IllegalAccessException;

    // 删除
    <T> int deleteByIdList(List<Long> idList, Class<T> targetClass);

    // 删除
    <T> int deleteByIdList(List<Long> idList, Class<T> targetClass, String tableName);

    // 删除
    <T> int deleteByCond(String cond, Class<T> targetClass);

    // 根据id查询
    <T> T queryById(Class<T> targetClass, Long id) throws Exception;

    // 根据id列表查询
    <T> List<T> queryByIdList(Class<T> targetClass, List<Long> idList) throws Exception;

    // 查询
    <T> List<T> queryByCond(String condition, Class<T> targetClass) throws Exception;

    // 查询
    <T> List<T> queryByCond(String condition, Map<String, Object> param, Class<T> targetClass) throws Exception;

    // 查询
    <T> List<T> queryByCond(String condition, Object[] param, Class<T> targetClass) throws Exception;

    // 查询
    <T> Long countByCond(String condition, Class<T> targetClass);
}
